$(function(){
	   easyloader.base = 'js/tools/easyui/';
	   using("locale/easyui-lang-zh_CN.js",function(){
	      var columns=[[
	                             {field:'checkbox',checkbox:true},
								  {field: 'id',title: 'id',hidden:true},
						          {field: 'title',title: '新闻标题',width: 200,align: 'left'},
								  {field: 'category',title: '所属一级分类',width: 120,align: 'left'},
						          {field: 'subcategory',title: '所属二级分类',width: 120,align: 'left'},
								  {field: 'recommend',title: '推荐',width: 120,align: 'left'},
								  {field: 'datetime',title: '添加时间',width: 120,align: 'left'},
								  {field: 'opt',title: '操作',width: 100,align: 'left'}
							 ]];
	         createDateGrid(columns,'news!newsListForJson.action',{searchStr:"","columnId":$.query.get("columnId")},false,560);
	   });
	   $("#dialog").dialog();
	   var columnId=$.query.get("columnId");
	categoryList("categoryId",columnId,-1);
});

//删除用户
function deleteNews(ids)
{
	$.getJSON("news!deleteNews.action",{"ids":ids},function(data){
		       if(data.info)
					{
						$("#dataGrid").datagrid("reload");
						alert("删除成功");
					}else
					{
						alert("删除失败");
					}
	});
}

//搜索
function searchData()
{
	var categoryId=$("#categoryId").val();
	var subCategoryId=$("#subCategoryId").val();
	var keyword=$.trim($("#keywords").val());
	var searchStr=categoryId+"_"+subCategoryId+"_"+keyword;
	$("#dataGrid")
	
var queryParams = $('#dataGrid').datagrid('options').queryParams;  
        queryParams.searchStr = searchStr;  
      queryParams.columnId = $.query.get("columnId");  
        $("#dataGrid").datagrid('reload'); 
}

//批量删除
function moreDelete()
{
	var rows= $("#dataGrid").datagrid("getSelections");
	var ids="";
	for(var i=0;i<rows.length;i++)
	{
		ids+=rows[i].id+",";
	}
	ids=ids.substring(0,ids.length-1);
	deleteNews(ids);
}
